import 'package:flutter/material.dart';

/// 记账应用的蓝色系粉嫩主题配置
class ExpenseTheme {
  // 主色调 - 蓝色系
  static const Color primaryBlue = Color(0xFF6BB6FF); // 主蓝色
  static const Color lightBlue = Color(0xFFB3D9FF); // 浅蓝色
  static const Color softBlue = Color(0xFFE6F3FF); // 柔和蓝色
  static const Color deepBlue = Color(0xFF4A90E2); // 深蓝色

  // 粉嫩色调
  static const Color pinkAccent = Color(0xFFFFB3D9); // 粉色点缀
  static const Color lavender = Color(0xFFE6E6FA); // 薰衣草色
  static const Color mintGreen = Color(0xFFB3FFE6); // 薄荷绿
  static const Color peach = Color(0xFFFFE6CC); // 桃色

  // 功能色彩
  static const Color incomeGreen = Color(0xFF4CAF50); // 收入绿色
  static const Color expenseRed = Color(0xFFFF6B6B); // 支出红色
  static const Color warningOrange = Color(0xFFFF9800); // 警告橙色

  // 中性色
  static const Color textPrimary = Color(0xFF2C3E50); // 主要文字
  static const Color textSecondary = Color(0xFF7F8C8D); // 次要文字
  static const Color textLight = Color(0xFFBDC3C7); // 浅色文字
  static const Color background = Color(0xFFF8FBFF); // 背景色
  static const Color cardBackground = Color(0xFFFFFFFF); // 卡片背景
  static const Color divider = Color(0xFFECF0F1); // 分割线

  /// 获取主题数据
  static ThemeData get themeData {
    return ThemeData(
      useMaterial3: true,
      colorScheme: ColorScheme.fromSeed(
        seedColor: primaryBlue,
        brightness: Brightness.light,
        primary: primaryBlue,
        secondary: pinkAccent,
        surface: cardBackground,
        background: background,
        error: expenseRed,
      ),

      // AppBar主题
      appBarTheme: const AppBarTheme(
        centerTitle: true,
        elevation: 0,
        backgroundColor: primaryBlue,
        foregroundColor: Colors.white,
        titleTextStyle: TextStyle(
          fontSize: 20,
          fontWeight: FontWeight.w600,
          color: Colors.white,
        ),
      ),

      // 卡片主题 - 暂时注释掉，因为版本兼容性问题
      // cardTheme: const CardTheme(
      //   elevation: 2,
      //   shadowColor: primaryBlue,
      //   shape: RoundedRectangleBorder(
      //     borderRadius: BorderRadius.all(Radius.circular(16)),
      //   ),
      //   color: cardBackground,
      // ),

      // 浮动按钮主题
      floatingActionButtonTheme: const FloatingActionButtonThemeData(
        backgroundColor: primaryBlue,
        foregroundColor: Colors.white,
        elevation: 4,
        shape: CircleBorder(),
      ),

      // 按钮主题
      elevatedButtonTheme: ElevatedButtonThemeData(
        style: ElevatedButton.styleFrom(
          backgroundColor: primaryBlue,
          foregroundColor: Colors.white,
          elevation: 2,
          padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(12),
          ),
        ),
      ),

      // 文本按钮主题
      textButtonTheme: TextButtonThemeData(
        style: TextButton.styleFrom(
          foregroundColor: primaryBlue,
          padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
          shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(8)),
        ),
      ),

      // 输入框主题
      inputDecorationTheme: InputDecorationTheme(
        filled: true,
        fillColor: softBlue,
        border: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide.none,
        ),
        enabledBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide(color: lightBlue, width: 1),
        ),
        focusedBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide(color: primaryBlue, width: 2),
        ),
        errorBorder: OutlineInputBorder(
          borderRadius: BorderRadius.circular(12),
          borderSide: BorderSide(color: expenseRed, width: 1),
        ),
        contentPadding: const EdgeInsets.symmetric(
          horizontal: 16,
          vertical: 12,
        ),
        labelStyle: TextStyle(color: textSecondary),
        hintStyle: TextStyle(color: textLight),
      ),

      // 底部导航栏主题
      bottomNavigationBarTheme: const BottomNavigationBarThemeData(
        backgroundColor: cardBackground,
        selectedItemColor: primaryBlue,
        unselectedItemColor: textSecondary,
        type: BottomNavigationBarType.fixed,
        elevation: 8,
      ),

      // 文本主题
      textTheme: const TextTheme(
        headlineLarge: TextStyle(
          fontSize: 32,
          fontWeight: FontWeight.bold,
          color: textPrimary,
        ),
        headlineMedium: TextStyle(
          fontSize: 28,
          fontWeight: FontWeight.w600,
          color: textPrimary,
        ),
        headlineSmall: TextStyle(
          fontSize: 24,
          fontWeight: FontWeight.w600,
          color: textPrimary,
        ),
        titleLarge: TextStyle(
          fontSize: 20,
          fontWeight: FontWeight.w600,
          color: textPrimary,
        ),
        titleMedium: TextStyle(
          fontSize: 18,
          fontWeight: FontWeight.w500,
          color: textPrimary,
        ),
        titleSmall: TextStyle(
          fontSize: 16,
          fontWeight: FontWeight.w500,
          color: textPrimary,
        ),
        bodyLarge: TextStyle(
          fontSize: 16,
          fontWeight: FontWeight.normal,
          color: textPrimary,
        ),
        bodyMedium: TextStyle(
          fontSize: 14,
          fontWeight: FontWeight.normal,
          color: textPrimary,
        ),
        bodySmall: TextStyle(
          fontSize: 12,
          fontWeight: FontWeight.normal,
          color: textSecondary,
        ),
        labelLarge: TextStyle(
          fontSize: 14,
          fontWeight: FontWeight.w500,
          color: textPrimary,
        ),
        labelMedium: TextStyle(
          fontSize: 12,
          fontWeight: FontWeight.w500,
          color: textSecondary,
        ),
        labelSmall: TextStyle(
          fontSize: 10,
          fontWeight: FontWeight.w500,
          color: textLight,
        ),
      ),

      // 图标主题
      iconTheme: const IconThemeData(color: textSecondary, size: 24),

      // 分割线主题
      dividerTheme: const DividerThemeData(
        color: divider,
        thickness: 1,
        space: 1,
      ),

      // 背景色
      scaffoldBackgroundColor: background,
    );
  }

  /// 获取渐变色
  static LinearGradient get primaryGradient {
    return const LinearGradient(
      begin: Alignment.topLeft,
      end: Alignment.bottomRight,
      colors: [primaryBlue, lightBlue],
    );
  }

  /// 获取收入渐变色
  static LinearGradient get incomeGradient {
    return const LinearGradient(
      begin: Alignment.topLeft,
      end: Alignment.bottomRight,
      colors: [incomeGreen, mintGreen],
    );
  }

  /// 获取支出渐变色
  static LinearGradient get expenseGradient {
    return const LinearGradient(
      begin: Alignment.topLeft,
      end: Alignment.bottomRight,
      colors: [expenseRed, pinkAccent],
    );
  }

  /// 获取卡片阴影
  static List<BoxShadow> get cardShadow {
    return [
      BoxShadow(
        color: primaryBlue.withValues(alpha: 0.1),
        blurRadius: 8,
        offset: const Offset(0, 2),
      ),
    ];
  }

  /// 获取柔和阴影
  static List<BoxShadow> get softShadow {
    return [
      BoxShadow(
        color: Colors.black.withValues(alpha: 0.05),
        blurRadius: 4,
        offset: const Offset(0, 1),
      ),
    ];
  }
}
